#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x

trigger-tar-deploy-source() {
  declare desc="tar deploy-source plugin trigger"
  declare trigger="deploy-source"
  declare APP="$1"
  local STDIN
  STDIN=$(cat)

  # bail if another source is detected
  if [[ -n "$STDIN" ]]; then
    echo "$STDIN"
    return
  fi

  if [[ -f "$DOKKU_ROOT/$APP/src.tar" ]]; then
    echo "tar"
  fi
}

trigger-tar-deploy-source "$@"
